package com.chen.corejava;

import java.io.Console;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.time.DateUtils;

/**
 *@author：email: <a href="cyb@ewppay.com"> Administrator </a> 
 *@Date 2017-2-9 下午3:36:35 
 */

public class Test {
	
	{
		System.out.println("初始化块");
	}
	
	static {
		System.out.println("静态初始化块");
	}

	/**
	 * @Description: 
	 * @param @param args   
	 * @return void  
	 * @throws
	 * @author cyb
	 * @date 2017-2-9
	 */
	public static void main(String[] args) {
		Test t = new Test();
		
//		List ll = new ArrayList();
//		String[] str = new String[]{"a","b"};
//		List list2 = Arrays.asList(str);
//		//list2.add("c");异常
//		str[0] = "d";
//		System.out.println(list2.get(0));//d
//		
//		String ss = "a,b,c,,";
//		String[] arry = ss.split(",");
//		System.out.println(arry.length);//3
//		
//		Date d;
//		try {
//			d = DateUtils.parseDate("2015-01-06", "yyyy-mm-dd");
//			System.out.println(d);
//		} catch (ParseException e) {
//			e.printStackTrace();
//		}
//    
//		
//		
//		
//		Student a = new Student("Alice",20);
//		Student b = new Student("Blob",30);
//		System.out.println(a);
//		System.out.println(a.getName());
//		Test.swap(a, b);
//		System.out.println(a.getName());
//		
//		ArrayList<Student> list = new ArrayList<Student>();
//		
//		System.out.println(Size.SMALL.toString());
//		Size s = Enum.valueOf(Size.class, "SMALL");
//		System.out.println(s);
//		
//		System.out.println(Size.SMALL.compareTo(Size.MIDDLE));
//		
//		int n = 5;
//		//System.out.println(n/0);
//		
//		float f = 0f;
//		System.out.println(f/0);//NAN
		
//		Console cons = System.console();
//		String username = cons.readLine("User name:");
//		char[] password = cons.readPassword("password:");
		int[][] odds = new int[5][];
		for(int i = 0;i<5;i++){
			odds[i] = new int[i+1];
		}
		
		for(int n = 0; n < odds.length; n++){
			for(int k = 0;k < odds[n].length;k++){
				int lotteryOdds = 1;
				for(int i = 1; i <= k;i++){
					lotteryOdds = lotteryOdds * (n - i + 1) / i;
				}
				odds[n][k] = lotteryOdds;
			}
		}
		
		for(int[] row : odds){
			for(int odd : row){
				System.out.printf("%4d", odd);
			}
			System.out.println();
		}
	}
	
	public static void swap(Student a, Student b){
		Student temp = a;
		a = b;
		b = temp;
	}

}
